package cn.itsource.pethome.org.controller;


import cn.itsource.pethome.base.domain.AjaxResult;
import cn.itsource.pethome.org.domain.Shop;
import cn.itsource.pethome.org.domain.ShopDTO;
import cn.itsource.pethome.org.service.EmployeeService;
import cn.itsource.pethome.org.service.ShopService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Api 店铺的controller
 */
@Api(value = "部门管理的接口文档",description = "部门管理的接口文档")
@RestController
@RequestMapping("shop")
@Slf4j
public class ShopController {

    @Autowired
    EmployeeService employeeService;
    @Autowired
    ShopService shopService;

    /**
     * 1.url :/shop/register 请求方式:post
     *
     * 2.入参:shop: {
     *                     employee: {},
     *                     shop: {}
     *                 }
     * 3.出参:AjaxResult
     */
    @PostMapping("/register")
    public AjaxResult register(@RequestBody @Valid ShopDTO shopDTO){

        shopService.register(shopDTO);
        return AjaxResult.me();
    }

    /**
     * 这个地方是用来给用户收到邮箱后点击激活使用的
     * @param uuid
     * @return
     */
    @GetMapping("/empl/state/{uuid}")
    public String emplState(@PathVariable("uuid")String uuid){

        String s = shopService.emplState(uuid);
        return s;
    }

    @GetMapping("/findAll")
    //@ResponseBody ,并且将对象转成json
    public List<Shop> findAll(){
        return shopService.findAll();
    }
}
